package com.foodie.servlet;

import com.foodie.entity.Meun1;
import com.foodie.service.MeunService1;
import com.google.gson.Gson;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
@WebServlet("/MenuDetails/Ajax")
public class GetMeunServlet extends HttpServlet {
    MeunService1 meunService1 = new MeunService1();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        List<Meun1> meun1List = meunService1.getList();
//        req.getSession().setAttribute("meun1List",meun1List);
        resp.setContentType("application/json;charset=utf-8");
        resp.getWriter().println(new Gson().toJson(meun1List));

    }
}
